<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <div>{{obj.name}}</div>
    <div v-if="obj.sex">性别正常显示</div>
    <div>{{obj.age}}</div>
    <div>{{obj.shengao}}</div>
  </div>
  <script src="./vue.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data() {
        return {
          msg: "你好",
          obj: {
            name: "王一博",
            sex: 0
          }
        }
      },
      mounted() {
        this.msg = "百威"
        this.obj.sex = 1;
        this.obj.age = 18;
        // 向响应式对象中添加一个 property，并确保这个新 property 同样是响应式的，
        // 且触发视图更新。它必须用于向响应式对象上添加新 property，
        // 因为 Vue 无法探测普通的新增 property (比如this.myObject.newProperty = 'hi')
        this.$set(this.obj, "shengao", "188")
        this.$set(this.obj, "age", 177)
      },
    })
    // 全局api
    vm.$set(vm.obj, "name", "珠江");




  </script>
</body>

</html>